/*
 * Module 02
 *
 */

package ua.gl.basecamp.tabachnyy.util;

import ua.gl.basecamp.tabachnyy.testcase.*;

import java.util.List;

/**
 * @author yaroslav.tabachnyy@gmail.com
 * @version 1.02
 * @date 14.02.2013
 *
 */
public class QuestionFactory {
    public static Question createQuestion(String type,
                                          String questionStringRepresentation,
                                          List<Answer> answers,
                                          Double maxDeviation) {
        if (type.equals("single")) {
            return new SingleAnswerQuestion(questionStringRepresentation, answers);
        } else if (type.equals("yesno")) {
            return new YesNoQuestion(questionStringRepresentation, answers);
        } else if (type.equals("multiple")) {
            return new MultipleAnswersQuestion(questionStringRepresentation, answers);
        } else if (type.equals("enterable")) {
            return new TypedAnswerQuestion(questionStringRepresentation, answers);
        } else if (type.equals("range")) {
            return new RangeAnswerQuestion(questionStringRepresentation, answers, maxDeviation);
        } else {
            throw new IllegalArgumentException("Unknown question type!");
        }
    }
}
